From 4db4a21930ea5baef78d4a24d5b2fee43c975829 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Tue, 29 Mar 2005 14:52:44 +0000 Subject: [PATCH] bitkeeper revision 1.1236.1.153 (42496bbcmDKIhBdeW5tCa1moqo8b-Q) Lazy pagetable and LDT switching was unsafe -- do them synchronously for now, and maybe think about batching across switch_mm and switch_to in the future (particularly for 2.6, which we care about more than 2.4). Signed-off-by: Keir Fraser --- linux-2.4.29-xen-sparse/arch/xen/kernel/ldt.c | 2 -- .../arch/xen/kernel/process.c | 29 ------------------- linux-2.4.29-xen-sparse/arch/xen/mm/fault.c | 1 - .../include/asm-xen/mmu_context.h | 18 +++--------- 4 files changed, 4 insertions(+), 46 deletions(-) diff --git a/linux-2.4.29-xen-sparse/arch/xen/kernel/ldt.c b/linux-2.4.29-xen-sparse/arch/xen/kernel/ldt.c index 79ac73960d..6235778493 100644 --- a/linux-2.4.29-xen-sparse/arch/xen/kernel/ldt.c +++ b/linux-2.4.29-xen-sparse/arch/xen/kernel/ldt.c @@ -117,8 +117,6 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm) void destroy_context(struct mm_struct *mm) { if (mm->context.size) { - if (mm_state_sync & STATE_SYNC_LDT) - clear_LDT(); make_pages_writable( mm->context.ldt, (mm->context.size*LDT_ENTRY_SIZE)/PAGE_SIZE); diff --git a/linux-2.4.29-xen-sparse/arch/xen/kernel/process.c b/linux-2.4.29-xen-sparse/arch/xen/kernel/process.c index 478184f504..c9d553627f 100644 --- a/linux-2.4.29-xen-sparse/arch/xen/kernel/process.c +++ b/linux-2.4.29-xen-sparse/arch/xen/kernel/process.c @@ -305,35 +305,6 @@ void fastcall __switch_to(struct task_struct *prev_p, struct task_struct *next_p struct thread_struct *next = &next_p->thread; physdev_op_t op; multicall_entry_t _mcl[8], *mcl = _mcl; - mmu_update_t _mmu[2], *mmu = _mmu; - - if ( mm_state_sync & STATE_SYNC_PT ) - { - mmu->ptr = virt_to_machine(cur_pgd) | MMU_EXTENDED_COMMAND; - mmu->val = MMUEXT_NEW_BASEPTR; - mmu++; - } - - if ( mm_state_sync & STATE_SYNC_LDT ) - { - __asm__ __volatile__ ( - "xorl %%eax,%%eax; movl %%eax,%%fs; movl %%eax,%%gs" : : : "eax" ); - mmu->ptr = (unsigned long)next_p->mm->context.ldt | - MMU_EXTENDED_COMMAND; - mmu->val = (next_p->mm->context.size << MMUEXT_CMD_SHIFT) | - MMUEXT_SET_LDT; - mmu++; - } - - if ( mm_state_sync != 0 ) - { - mcl->op = __HYPERVISOR_mmu_update; - mcl->args[0] = (unsigned long)_mmu; - mcl->args[1] = mmu - _mmu; - mcl->args[2] = 0; - mcl++; - mm_state_sync = 0; - } /* * This is basically 'unlazy_fpu', except that we queue a multicall to diff --git a/linux-2.4.29-xen-sparse/arch/xen/mm/fault.c b/linux-2.4.29-xen-sparse/arch/xen/mm/fault.c index 1fd1b4c149..7db6463e09 100644 --- a/linux-2.4.29-xen-sparse/arch/xen/mm/fault.c +++ b/linux-2.4.29-xen-sparse/arch/xen/mm/fault.c @@ -28,7 +28,6 @@ extern void die(const char *,struct pt_regs *,long); pgd_t *cur_pgd; -int mm_state_sync; extern spinlock_t timerlist_lock; diff --git a/linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h b/linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h index 60c245e408..2aea8e2f1a 100644 --- a/linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h +++ b/linux-2.4.29-xen-sparse/include/asm-xen/mmu_context.h @@ -28,9 +28,6 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk, #endif extern pgd_t *cur_pgd; -extern int mm_state_sync; -#define STATE_SYNC_PT 1 -#define STATE_SYNC_LDT 2 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu) { @@ -39,23 +36,16 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, str clear_bit(cpu, &prev->cpu_vm_mask); /* Re-load page tables */ cur_pgd = next->pgd; - mm_state_sync |= STATE_SYNC_PT; + xen_pt_switch(__pa(cur_pgd)); /* load_LDT, if either the previous or next thread * has a non-default LDT. */ if (next->context.size+prev->context.size) - mm_state_sync |= STATE_SYNC_LDT; + load_LDT(&next->context); } } -#define activate_mm(prev, next) \ -do { \ - switch_mm((prev),(next),NULL,smp_processor_id()); \ - if (mm_state_sync & STATE_SYNC_PT) \ - xen_pt_switch(__pa(cur_pgd)); \ - if (mm_state_sync & STATE_SYNC_LDT) \ - load_LDT(&(next)->context); \ - mm_state_sync = 0; \ -} while ( 0 ) +#define activate_mm(prev, next) \ + switch_mm((prev),(next),NULL,smp_processor_id()) #endif -- 2.30.2